// 加载页面

var h1 = true;
var er1 = true;
var bz = 0;
var h = true;
var er = true;
var sw = 0;
var wer = true;


function Div() {
    document.getElementById("qwas").style.visibility = " hidden";
    var a = document.getElementById("x")
    for (i = 0; i <= 12; i++) {
        var as = "";
        for (j = 0; j <= 12; j++) {
            if ((i == 1 || i == 11 || j == 1 || j == 11) && (i != 0 && j != 0 && i != 12 && j != 12)) {
                as += `<span id="a${i}b${j}" name="a0" class="a2"></span>`
            } else if ((i == 3 || i == 5 || i == 7 || i == 9) && (j == 3 || j == 5 || j == 7 || j == 9) && (i != 0 && j != 0 && i != 12 && j != 12)) {
                as += `<span id="a${i}b${j}" name="a0" class="a2"></span>`
            } else if (i != 0 && j != 0 && i != 12 && j != 12) {
                as += `<span id="a${i}b${j}" name="a1" class="a1"></span>`
            } else {
                as += `<span id="a${i}b${j}" name="a1" class="a8"></span>`
            }
        }
        a.innerHTML += `<div>${as}</div>`;
    }
    for (i = 1; i <= 11; i++) {
        for (j = 1; j <= 11; j++) {
            document.getElementById(`a${i}b${j}`).Value = 0;
        }
    }
}

// 移动url('img/2.jpeg')
function rt() {
    document.getElementById("a2b2").innerHTML = `<img src="img/21.jpeg">`;
    document.getElementById("a10b10").innerHTML = `<img src="img/321234.jpeg">`;
    document.getElementById("a2b2").Value = 1;
    document.getElementById("a10b10").Value = 3;
}
//kaishi
function fv() {
    document.getElementById("x").innerHTML = ''
    h1 = true;
    er1 = true;
    bz = 0;
    h = true;
    er = true;
    sw = 1
    Div();
    rt();
    document.getElementById("yui").style.visibility = " hidden"
    document.getElementById("vbs").style.visibility = " hidden";
    document.getElementById("vbs1").style.visibility = " hidden";
}
function fv1() {
    document.getElementById("x").innerHTML = ''
    h1 = true;
    er1 = true;
    bz = 0;
    h = true;
    er = true;
    sw = 0;
    Div();
    rt();
    wer = true;
    wanjia();
    avt();
    document.getElementById("yui").style.visibility = " visible"
    document.getElementById("vbs").style.visibility = " hidden";
    document.getElementById("vbs1").style.visibility = " hidden";
}


// 右移
function move() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i}b${j + 1}`).Value != 3 && document.getElementById(`a${i}b${j + 1}`).style.backgroundImage.length != 20 && document.getElementById(`a${i}b${j}`).Value == 1 && document.getElementById(`a${i}b${j + 1}`).style.backgroundImage.length != 17 && document.getElementById(`a${i}b${j + 1}`).getAttribute("name")[1] == 1) {
                if (document.getElementById(`a${i}b${j + 1}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = 3;
                    document.getElementById(`a${i - 1}b${j}`).Value = 3;
                    document.getElementById(`a${i}b${j + 1}`).Value = 3;
                    document.getElementById(`a${i}b${j - 1}`).Value = 3;
                    document.getElementById(`a${i}b${j}`).Value == 3;
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i}b${j + 1}`).innerHTML = `<img src="img/21.jpeg">`;
                    document.getElementById(`a${i}b${j + 1}`).Value = 1;
                    document.getElementById(`a${i}b${j}`).Value = 0;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}
// 左移
function move1() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i}b${j - 1}`).Value != 3 && document.getElementById(`a${i}b${j - 1}`).style.backgroundImage.length != 20 && document.getElementById(`a${i}b${j}`).Value == 1 && document.getElementById(`a${i}b${j - 1}`).style.backgroundImage.length != 17 && document.getElementById(`a${i}b${j - 1}`).getAttribute("name")[1] == 1) {
                if (document.getElementById(`a${i}b${j - 1}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = 3
                    document.getElementById(`a${i - 1}b${j}`).Value = 3
                    document.getElementById(`a${i}b${j + 1}`).Value = 3
                    document.getElementById(`a${i}b${j - 1}`).Value = 3
                    document.getElementById(`a${i}b${j}`).Value = 3;
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i}b${j - 1}`).innerHTML = `<img src="img/21.jpeg">`;
                    document.getElementById(`a${i}b${j - 1}`).Value = 1;
                    document.getElementById(`a${i}b${j}`).Value = 0;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}
// 下移
function move2() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i + 1}b${j}`).Value != 3 && document.getElementById(`a${i + 1}b${j}`).style.backgroundImage.length != 20 && document.getElementById(`a${i}b${j}`).Value == 1 && document.getElementById(`a${i + 1}b${j}`).style.backgroundImage.length != 17 && document.getElementById(`a${i + 1}b${j}`).getAttribute("name")[1] == 1) {
                if (document.getElementById(`a${i + 1}b${j}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = 3
                    document.getElementById(`a${i - 1}b${j}`).Value = 3
                    document.getElementById(`a${i}b${j + 1}`).Value = 3
                    document.getElementById(`a${i}b${j - 1}`).Value = 3
                    document.getElementById(`a${i}b${j}`).Value = 3;
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i + 1}b${j}`).innerHTML = `<img src="img/21.jpeg">`;
                    document.getElementById(`a${i + 1}b${j}`).Value = 1;
                    document.getElementById(`a${i}b${j}`).Value = 0;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}
// 上移
function move3() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i - 1}b${j}`).Value != 3 && document.getElementById(`a${i - 1}b${j}`).style.backgroundImage.length != 20 && document.getElementById(`a${i}b${j}`).Value == 1 && document.getElementById(`a${i - 1}b${j}`).getAttribute("name")[1] == 1 && document.getElementById(`a${i - 1}b${j}`).style.backgroundImage.length != 17) {
                if (document.getElementById(`a${i - 1}b${j}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j}`).Value = 3;
                    document.getElementById(`a${i + 1}b${j}`).Value = 3
                    document.getElementById(`a${i - 1}b${j}`).Value = 3
                    document.getElementById(`a${i}b${j + 1}`).Value = 3
                    document.getElementById(`a${i}b${j - 1}`).Value = 3
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i - 1}b${j}`).innerHTML = `<img src="img/21.jpeg">`;
                    document.getElementById(`a${i - 1}b${j}`).Value = 1;
                    document.getElementById(`a${i}b${j}`).Value = 0;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}

// 放置console.log(document.getElementById(`a2b1`).getAttribute("name")[1]);

function move4() {
    while (er) {
        for (i = 2; i <= 10; i++) {
            for (j = 2; j <= 10; j++) {
                if (document.getElementById(`a${i}b${j}`).Value == 1) {
                    document.getElementById(`a${i}b${j}`).style.backgroundImage = `url('img/1.jpeg')`

                    move5(i, j)
                    return false;
                }
            }
        }
    }
}
// e爆炸  、、
function move5(i, j) {
    setTimeout(function move5() {
        while (h) {
            if (document.getElementById(`a${i}b${j}`).style.backgroundImage.length == 17 || document.getElementById(`a${i}b${j}`).style.backgroundImage.length == 19) {

                document.getElementById(`a${i}b${j}`).style.backgroundImage = `url('img/300.jpeg')`
                if (document.getElementById(`a${i - 1}b${j}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i - 1}b${j}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                if (document.getElementById(`a${i + 1}b${j}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i + 1}b${j}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                if (document.getElementById(`a${i}b${j + 1}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i}b${j + 1}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                if (document.getElementById(`a${i}b${j - 1}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i}b${j - 1}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                var w = i;
                var q = j;
                h = false;
                if (document.getElementById(`a${i}b${j}`).Value == 1 || document.getElementById(`a${i}b${j}`).Value == 3) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById(`a${i + 1}b${j}`).Value == 1 || document.getElementById(`a${i + 1}b${j}`).Value == 3) {
                    document.getElementById(`a${i + 1}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById(`a${i - 1}b${j}`).Value == 1 || document.getElementById(`a${i - 1}b${j}`).Value == 3) {
                    document.getElementById(`a${i - 1}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i - 1}b${j}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById(`a${i}b${j + 1}`).Value == 1 || document.getElementById(`a${i}b${j + 1}`).Value == 3) {
                    document.getElementById(`a${i}b${j + 1}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j + 1}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById(`a${i}b${j - 1}`).Value == 1 || document.getElementById(`a${i}b${j - 1}`).Value == 3) {
                    document.getElementById(`a${i}b${j - 1}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j - 1}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                setTimeout(function move6() {
                    document.getElementById(`a${w}b${q}`).style.backgroundImage = `url('img/6666666666.png')`;
                    if (document.getElementById(`a${w}b${q + 1}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${w}b${q + 1}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    if (document.getElementById(`a${w}b${q - 1}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${w}b${q - 1}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    if (document.getElementById(`a${w + 1}b${q}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${w + 1}b${q}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    if (document.getElementById(`a${w - 1}b${q}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${w - 1}b${q}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    h = true;
                    er = true;
                }, 800)

                return;
            }
            return;
        }
    }, 1500)

}






// 右移
function move106() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i}b${j + 1}`).Value != 1 && document.getElementById(`a${i}b${j + 1}`).style.backgroundImage.length != 20 && document.getElementById(`a${i}b${j}`).Value == 3 && document.getElementById(`a${i}b${j + 1}`).style.backgroundImage.length != 17 && document.getElementById(`a${i}b${j + 1}`).getAttribute("name")[1] == 1) {
                if (document.getElementById(`a${i}b${j + 1}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = bz;
                    document.getElementById(`a${i - 1}b${j}`).Value = bz;
                    document.getElementById(`a${i}b${j + 1}`).Value = bz;
                    document.getElementById(`a${i}b${j - 1}`).Value = bz;
                    document.getElementById(`a${i}b${j}`).Value == bz;
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i}b${j + 1}`).innerHTML = `<img src="img/321234.jpeg">`;
                    document.getElementById(`a${i}b${j + 1}`).Value = 3;
                    document.getElementById(`a${i}b${j}`).Value = 0;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}
// 左移
function move105() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i}b${j - 1}`).Value != 1 && document.getElementById(`a${i}b${j - 1}`).style.backgroundImage.length != 20 && document.getElementById(`a${i}b${j}`).Value == 3 && document.getElementById(`a${i}b${j - 1}`).style.backgroundImage.length != 17 && document.getElementById(`a${i}b${j - 1}`).getAttribute("name")[1] == 1) {
                if (document.getElementById(`a${i}b${j - 1}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = bz
                    document.getElementById(`a${i - 1}b${j}`).Value = bz
                    document.getElementById(`a${i}b${j + 1}`).Value = bz
                    document.getElementById(`a${i}b${j - 1}`).Value = bz
                    document.getElementById(`a${i}b${j}`).Value = bz;
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i}b${j - 1}`).innerHTML = `<img src="img/321234.jpeg">`;
                    document.getElementById(`a${i}b${j - 1}`).Value = 3;
                    document.getElementById(`a${i}b${j}`).Value = bz;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}
// 下移
function move104() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i + 1}b${j}`).Value != 1 && document.getElementById(`a${i}b${j}`).Value == 3 && document.getElementById(`a${i + 1}b${j}`).style.backgroundImage.length != 17 && document.getElementById(`a${i + 1}b${j}`).getAttribute("name")[1] == 1 && document.getElementById(`a${i + 1}b${j}`).style.backgroundImage.length != 20) {
                if (document.getElementById(`a${i + 1}b${j}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = bz
                    document.getElementById(`a${i - 1}b${j}`).Value = bz
                    document.getElementById(`a${i}b${j + 1}`).Value = bz
                    document.getElementById(`a${i}b${j - 1}`).Value = bz
                    document.getElementById(`a${i}b${j}`).Value = bz;
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i + 1}b${j}`).innerHTML = `<img src="img/321234.jpeg">`;
                    document.getElementById(`a${i + 1}b${j}`).Value = 3;
                    document.getElementById(`a${i}b${j}`).Value = bz;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}
// 上移
function move103() {
    for (i = 2; i <= 10; i++) {
        for (j = 2; j <= 10; j++) {
            if (document.getElementById(`a${i - 1}b${j}`).Value != 1 && document.getElementById(`a${i}b${j}`).Value == 3 && document.getElementById(`a${i - 1}b${j}`).getAttribute("name")[1] == 1 && document.getElementById(`a${i - 1}b${j}`).style.backgroundImage.length != 17 && document.getElementById(`a${i - 1}b${j}`).style.backgroundImage.length != 20) {
                if (document.getElementById(`a${i - 1}b${j}`).style.backgroundImage.length == 19) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j}`).Value = bz;
                    document.getElementById(`a${i + 1}b${j}`).Value = bz
                    document.getElementById(`a${i - 1}b${j}`).Value = bz
                    document.getElementById(`a${i}b${j + 1}`).Value = bz
                    document.getElementById(`a${i}b${j - 1}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById("qwas").style.visibility != "visible") {
                    document.getElementById(`a${i - 1}b${j}`).innerHTML = `<img src="img/321234.jpeg">`;
                    document.getElementById(`a${i - 1}b${j}`).Value = 3;
                    document.getElementById(`a${i}b${j}`).Value = bz;
                    document.getElementById(`a${i}b${j}`).innerHTML = ``
                    return;
                }
            }
        }
    }
}

// 放置
//console.log(document.getElementById(`a2b1`).getAttribute("name")[1]);

function move102() {
    while (er1) {
        for (i = 2; i <= 10; i++) {
            for (j = 2; j <= 10; j++) {
                if (document.getElementById(`a${i}b${j}`).Value == 3) {
                    document.getElementById(`a${i}b${j}`).style.backgroundImage = `url('img/1234.jpeg')`
                    move101(i, j)
                    return
                }
            }
        }
    }
}
//k 爆炸  、、
function move101(i, j) {
    setTimeout(function move5() {
        while (h1) {
            if (document.getElementById(`a${i}b${j}`).style.backgroundImage.length == 20 || document.getElementById(`a${i}b${j}`).style.backgroundImage.length == 19) {
                document.getElementById(`a${i}b${j}`).style.backgroundImage = `url('img/300.jpeg')`
                if (document.getElementById(`a${i - 1}b${j}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i - 1}b${j}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                if (document.getElementById(`a${i + 1}b${j}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i + 1}b${j}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                if (document.getElementById(`a${i}b${j + 1}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i}b${j + 1}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                if (document.getElementById(`a${i}b${j - 1}`).getAttribute("name")[1] == 1) {
                    document.getElementById(`a${i}b${j - 1}`).style.backgroundImage = `url('img/300.jpeg')`
                }
                var p = i;
                var r = j;
                h1 = false;
                if (document.getElementById(`a${i}b${j}`).Value == 1 || document.getElementById(`a${i}b${j}`).Value == 3) {
                    document.getElementById(`a${i}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j}`).Value = bz
                    wer = false;
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    return;
                }
                if (document.getElementById(`a${i + 1}b${j}`).Value == 1 || document.getElementById(`a${i + 1}b${j}`).Value == 3) {
                    document.getElementById(`a${i + 1}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i + 1}b${j}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById(`a${i - 1}b${j}`).Value == 1 || document.getElementById(`a${i - 1}b${j}`).Value == 3) {
                    document.getElementById(`a${i - 1}b${j}`).innerHTML = ``;
                    document.getElementById(`a${i - 1}b${j}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById(`a${i}b${j + 1}`).Value == 1 || document.getElementById(`a${i}b${j + 1}`).Value == 3) {
                    document.getElementById(`a${i}b${j + 1}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j + 1}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                if (document.getElementById(`a${i}b${j - 1}`).Value == 1 || document.getElementById(`a${i}b${j - 1}`).Value == 3) {
                    document.getElementById(`a${i}b${j - 1}`).innerHTML = ``;
                    document.getElementById(`a${i}b${j - 1}`).Value = bz
                    document.getElementById("qwas").style.visibility = "visible";
                    document.getElementById("vbs").style.visibility = " visible";
                    document.getElementById("vbs1").style.visibility = " visible";
                    wer = false;
                    return;
                }
                setTimeout(function move7() {
                    document.getElementById(`a${p}b${r}`).style.backgroundImage = `url('img/6666666666.png')`;
                    if (document.getElementById(`a${p}b${r + 1}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${p}b${r + 1}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    if (document.getElementById(`a${p}b${r - 1}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${p}b${r - 1}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    if (document.getElementById(`a${p + 1}b${r}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${p + 1}b${r}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    if (document.getElementById(`a${p - 1}b${r}`).style.backgroundImage.length == 19) {
                        document.getElementById(`a${p - 1}b${r}`).style.backgroundImage = `url('img/6666666666.png')`;
                    }
                    h1 = true;
                    er1 = true;
                }, 800)
                return;
            }
            return;
        }
    }, 1500)
}



//diannaoyidong
function wanjia() {
    setTimeout(function wan() {
        if (!wer) {
            return;
        }
        wanjia();
        var num = parseInt(Math.random() * 5 + 1)

        if (num == 1) {
            //er1 = move102()
            num = 2;
        }
        if (num == 2) {

            for (i = 2; i <= 10; i++) {
                for (j = 2; j <= 10; j++) {
                    if (document.getElementById(`a${i}b${j}`).Value == 3 &&
                        document.getElementById(`a${i}b${j - 1}`).style.backgroundImage.length != 19 &&

                        document.getElementById(`a${i}b${j - 2}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i}b${j - 2}`).style.backgroundImage.length != 20 &&

                        document.getElementById(`a${i - 1}b${j - 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i - 1}b${j - 1}`).style.backgroundImage.length != 20 &&
                        document.getElementById(`a${i + 1}b${j - 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i + 1}b${j - 1}`).style.backgroundImage.length != 20) {
                        if (document.getElementById(`a${i}b${j - 1}`).getAttribute("name")[1] == 0) {
                            num = 3;
                        } else {
                            move105();
                            return;
                        }

                    }
                }
            }
            num = 3;
            //zuo
        }
        if (num == 3) {
            for (i = 2; i <= 10; i++) {
                for (j = 2; j <= 10; j++) {
                    if (document.getElementById(`a${i}b${j}`).Value == 3 &&
                        document.getElementById(`a${i - 1}b${j}`).style.backgroundImage.length != 19 &&

                        document.getElementById(`a${i - 2}b${j}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i - 2}b${j}`).style.backgroundImage.length != 20 &&

                        document.getElementById(`a${i - 1}b${j - 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i - 1}b${j - 1}`).style.backgroundImage.length != 20 &&
                        document.getElementById(`a${i - 1}b${j + 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i - 1}b${j + 1}`).style.backgroundImage.length != 20) {
                        if (document.getElementById(`a${i - 1}b${j}`).getAttribute("name")[1] == 0) {
                            num = 4;
                        } else {
                            move103();
                            return;
                        }


                    }
                }
            }
            num = 4;

            //shang

        }
        if (num == 4) {

            for (i = 2; i <= 10; i++) {
                for (j = 2; j <= 10; j++) {
                    if (document.getElementById(`a${i}b${j}`).Value == 3 &&
                        document.getElementById(`a${i}b${j + 1}`).style.backgroundImage.length != 19 &&

                        document.getElementById(`a${i}b${j + 2}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i}b${j + 2}`).style.backgroundImage.length != 20 &&

                        document.getElementById(`a${i - 1}b${j + 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i - 1}b${j + 1}`).style.backgroundImage.length != 20 &&
                        document.getElementById(`a${i + 1}b${j + 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i + 1}b${j + 1}`).style.backgroundImage.length != 20) {
                        if (document.getElementById(`a${i}b${j + 1}`).getAttribute("name")[1] == 0) {
                            num = 5;
                        } else {
                            move106();
                            return
                        }

                    }
                }
            }

            num = 5;
            //you

        }
        if (num == 5) {
            for (i = 2; i <= 10; i++) {
                for (j = 2; j <= 10; j++) {
                    if (document.getElementById(`a${i}b${j}`).Value == 3 &&
                        document.getElementById(`a${i + 1}b${j}`).style.backgroundImage.length != 19 &&

                        document.getElementById(`a${i + 2}b${j}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i + 2}b${j}`).style.backgroundImage.length != 20 &&

                        document.getElementById(`a${i + 1}b${j - 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i + 1}b${j - 1}`).style.backgroundImage.length != 20 &&
                        document.getElementById(`a${i + 1}b${j + 1}`).style.backgroundImage.length != 17 &&
                        document.getElementById(`a${i + 1}b${j + 1}`).style.backgroundImage.length != 20) {
                        if (document.getElementById(`a${i + 1}b${j}`).getAttribute("name")[1] == 0) {
                            num = 2;
                        } else {
                            move104();
                            return;
                        }

                    }
                }
            }
            num = 2;
            //xia

        }


    }, 400);
}

//计时器
var time = 30
function avt() {
    if (document.getElementById("qwas").style.visibility == "visible") {
        time = 30;
        return;
    }
    if (time == -1) {
        time = 30
        for (i = 2; i <= 10; i++) {
            for (j = 2; j <= 10; j++) {
                document.getElementById(`a${i}b${j}`).style.backgroundImage = `url('img/300.jpeg')`
            }
        }
        return;
    }
    document.getElementById("yui").innerHTML = `剩余${time}秒`
    time--;
    setTimeout(function a() { avt() }, 1000)
}




//处理键盘事件  
function doKey(e) {
    var ev = e || window.event;                             //获取event对象  
    var obj = ev.target || ev.srcElement;                   //获取事件源  
    var t = obj.type || obj.getAttribute('type');           //获取事件源类型  
    if (ev.keyCode == 13 && sw == 1) {
        // 回车
        er1 = move102()

        return true;
    }
    if (ev.keyCode == 37 && sw == 1) {
        //左键
        move105()
        return true;
    }
    if (ev.keyCode == 38 && sw == 1) {
        //上键  
        move103()
        return true;
    }
    if (ev.keyCode == 39 && sw == 1) {
        //右边
        move106();
        return true;
    }
    if (ev.keyCode == 40 && sw == 1) {
        //下键
        move104()
        return true;
    }



    if (ev.keyCode == 87) {
        //W键
        move3()
        return true;
    } if (ev.keyCode == 65) {
        //A键
        move1()
        return true;
    } if (ev.keyCode == 83) {
        //S键
        move2()
        return true;
    } if (ev.keyCode == 68) {
        //D键
        move()
        return true;
    }
    if (ev.keyCode == 32) {
        //空格键
        er = move4()
        return true;
    }

}
//禁止后退键 作用于Firefox、Opera  
document.onkeypress = doKey;
//禁止后退键  作用于IE、Chrome  
document.onkeydown = doKey;

// w = 87
// a = 65
// s = 83
// d = 68